package com.appwoo.txtws.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import java.util.Timer;
import java.util.TimerTask;

public class BookstoreSearchActivity extends BookActivity
  implements View.OnClickListener, TextWatcher
{
  private String before;
  private int bookType;
  private Button mBtnBookstoreSearchOrCancle;
  private EditText mEditBookstoreSearchKeyword;
  private ImageView mIvBookstoreSearchClear;
  private String strGrade;
  private String subject;

  private void findView()
  {
    Intent localIntent = getIntent();
    this.bookType = localIntent.getIntExtra("bookType", -1);
    this.strGrade = localIntent.getStringExtra("grade");
    this.subject = localIntent.getStringExtra("subject");
    this.before = getIntent().getStringExtra("before");
    if ((this.before == null) || ("".equals(this.before)))
    {
      if (this.bookType == -1)
        finish();
      if (this.strGrade == null)
        finish();
    }
    this.mEditBookstoreSearchKeyword = ((EditText)findViewById(2131493000));
    this.mIvBookstoreSearchClear = ((ImageView)findViewById(2131493001));
    this.mBtnBookstoreSearchOrCancle = ((Button)findViewById(2131493002));
  }

  private void hiddenBookstoreSearchClear()
  {
    this.mIvBookstoreSearchClear.setVisibility(8);
    this.mIvBookstoreSearchClear.setOnClickListener(null);
    this.mBtnBookstoreSearchOrCancle.setText(2131427531);
  }

  private void setView()
  {
    this.mEditBookstoreSearchKeyword.addTextChangedListener(this);
    this.mBtnBookstoreSearchOrCancle.setOnClickListener(this);
  }

  private void showBookstoreSearchClear()
  {
    this.mIvBookstoreSearchClear.setVisibility(0);
    this.mIvBookstoreSearchClear.setOnClickListener(this);
    this.mBtnBookstoreSearchOrCancle.setText(2131428153);
  }

  public void afterTextChanged(Editable paramEditable)
  {
    if ((this.mEditBookstoreSearchKeyword.getText() != null) && (!"".equals(this.mEditBookstoreSearchKeyword.getText().toString().trim())))
    {
      showBookstoreSearchClear();
      return;
    }
    hiddenBookstoreSearchClear();
  }

  protected void backKeyCallBack()
  {
    super.backKeyCallBack();
    finish();
  }

  public void beforeTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3)
  {
  }

  public void onClick(View paramView)
  {
    switch (paramView.getId())
    {
    default:
      return;
    case 2131493002:
      String str = this.mEditBookstoreSearchKeyword.getText().toString();
      if ((str != null) && (!"".equals(str)))
      {
        if ((this.before != null) && (!"".equals(this.before)))
        {
          Intent localIntent2 = new Intent();
          localIntent2.putExtra("keyword", str);
          setResult(-1, localIntent2);
          finish();
          return;
        }
        Intent localIntent1 = new Intent(this, BookstoreResultActivity.class);
        localIntent1.putExtra("keyword", str);
        localIntent1.putExtra("bookType", this.bookType);
        localIntent1.putExtra("grade", this.strGrade);
        localIntent1.putExtra("subject", this.subject);
        startActivity(localIntent1);
        finish();
        return;
      }
      finish();
      return;
    case 2131493001:
    }
    this.mEditBookstoreSearchKeyword.setText(null);
    hiddenBookstoreSearchClear();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903066);
    findView();
    setView();
  }

  protected void onResume()
  {
    super.onResume();
    this.mEditBookstoreSearchKeyword.requestFocus();
    new Timer().schedule(new TimerTask()
    {
      public void run()
      {
        InputMethodManager localInputMethodManager = (InputMethodManager)BookstoreSearchActivity.this.getSystemService("input_method");
        localInputMethodManager.showSoftInput(BookstoreSearchActivity.this.mEditBookstoreSearchKeyword, 2);
        localInputMethodManager.toggleSoftInput(2, 1);
      }
    }
    , 300L);
  }

  public void onTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3)
  {
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.BookstoreSearchActivity
 * JD-Core Version:    0.6.2
 */